home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / Snippets / Development Tools & Languages / AEGestalt / Definitions.h < prev    next >
Encoding:
Text File  |  1995-02-12  |  3.1 KB  |  121 lines  |  [TEXT/MPS ]

  1. //     Definitions.h
  2. //     Copyright ©1992 Apple Computer, Inc.
  3. //    Kent Sandvik DTS
  4. //    This file contains debugger macros
  5. //    Version Info (latest first):
  6. //
  7. //    <1>        khs        1.0        First final version
  8.  
  9.  
  10. #ifndef __DEFINITIONS__
  11. #define __DEFINITIONS__
  12.  
  13. #ifndef __TYPES__
  14. #include <Types.h>
  15. #endif
  16.  
  17.  
  18. /*     DEBUGGER FLAGS
  19.   MacApp 3.0 has many special flags which could be turned on/off from the
  20.   debug menu entry. We are mostly interested in signalling something from
  21.   the application to the source code, so we are interested to use:
  22.   gIntenseDebugging - turn on intense debugging, it will also signal to the
  23.   framework to start tracing many other things, so it's very costly.
  24.   gUserFlag1, gUserFlag2, gUserFlag3 - these are better suited for special control
  25.   that we know about. In this case we are using gUserFlag1.
  26.   WHY DON'T YOU USE MACROS, INSTEAD INLINE FUNCTIONS?
  27.   Because I'm sick-n-tired of tracing macro based problems. It should not matter,
  28.   we are still inlining code directly instead of calling functions. Also, then
  29.   I'm able to use static variables for certain 'macros' which should only do something
  30.   based on earlier state.
  31.   TMON USE
  32.   These macros are defined for MacsBug, i.e. they start with a ';' in the beginning
  33.   of the string. If you want to use TMON, change the ';' to a '™' and also change the debugger
  34.   statement to something suitable in the TMON world. BTW, these macros are based on
  35.   MacsBug 6.2.2.
  36. */
  37.  
  38. //    Globals
  39. Boolean gHeapScramble = FALSE;                    // heap scrambling
  40. Boolean gLeaks = FALSE;                            // if Leaks DCMD is installed, test for memory leaks
  41.  
  42.  
  43. inline void DBOUTPUT(CStr255 a)                    //    Call debugger with a string - used for other macros.
  44. {
  45.     if (gUserFlag1)
  46.         DebugStr(a);
  47. }
  48.  
  49.  
  50. inline void DBHEAPCHECK()                        //    Heap Check - check for heap status, it stops if something is wrong
  51. {
  52.     DBOUTPUT(";HC; G");
  53. }
  54.  
  55.  
  56. inline void DBHEAPCHECKLOG()                    //    Heap Check variation - log information inside a log file
  57. {
  58.     DBOUTPUT("Extended Heap Check:; LOG HeapTest; WH; HC; HZ; LOG; G");
  59. }
  60.  
  61.  
  62. inline void DBHEAPSCRAMBLEON()                    //    Turn on Heap Scramble
  63. {
  64.     if (!gHeapScramble)
  65.     {
  66.         DBOUTPUT("Heap Scramble ON; HS; G");
  67.         gHeapScramble = TRUE;
  68.     }
  69. }
  70.  
  71.  
  72. inline void DBHEAPSCRAMBLEOFF()                    //    Turn off Heap Scramble
  73. {
  74.     if (gHeapScramble)
  75.     {
  76.         DBOUTPUT("Heap Scramble OFF; HS; G");
  77.         gHeapScramble = FALSE;
  78.     }
  79. }
  80.  
  81.  
  82. inline void DBHEAPINFOLOG()                        //    Log Heap information into log
  83. {
  84.     DBOUTPUT("Heap Info:; LOG HeapInfo; WH; HT; HD RS; LOG; G");
  85. }
  86.  
  87.  
  88. inline void DBEVENTRECORDLOG()                    // Log Event Records at particular instances
  89. {
  90.     DBOUTPUT("Event Record:; LOG EventRecordLog; WH; DM 000234C4 EventRecord; LOG; G");
  91. }
  92.  
  93.  
  94. inline void DBLEAKSON()                            //    Turn on Leaks dcmd (assume we have it installed, if not it's on Developer CD)
  95. {
  96.     if (!gLeaks)
  97.     {
  98.         DBOUTPUT("Leaks ON; Leaks On; G");
  99.         gLeaks = TRUE;
  100.     }
  101. }
  102.  
  103.  
  104. inline void DBLEAKSOFF()                        //    Turn off Leaks dcmd
  105. {
  106.     if (gLeaks)
  107.     {
  108.         DBOUTPUT("Leaks OFF; Leaks Off; G");
  109.         gLeaks = FALSE;
  110.     }
  111. }
  112.  
  113.  
  114. //  I think you got the idea now, feel free to create any other MacsBug/low level debugger
  115. //    commands which could be used from debug mode (or actually any other Macintosh source code
  116. //    which could set a flag dynamically from the Debugger menu).
  117.  
  118.  
  119. #endif
  120.  
  121.